 /**
 * v-hasRole 角色权限处理
 * Copyright (c) 2019 ruoyi
 */
 
import useUserStore from '@/store/modules/user'
import auth from '@/plugins/auth.js'
export default {
  mounted(el, binding, vnode) {
    const { arg,value } = binding
    const super_admin = "admin";
    const roles = useUserStore().roles

    if (value && value instanceof Array && value.length > 0) {
      const roleFlag = value

      let hasRole = false;
      switch (arg) {
      	case 'or':
      		hasRole = auth.hasRoleOr(permissions);
      		break;
      	case 'and':
      		hasRole = auth.hasRoleAnd(permissions);
      		break;
      	default:
      		hasRole = auth.hasRole(permissions);
      		break;
      }
      if (!hasRole) {
        el.parentNode && el.parentNode.removeChild(el)
      }
    } else {
      throw new Error(`请设置角色权限标签值"`)
    }
  }
}
